﻿
Imports Cls_Common
Imports VSModel
Partial Class FrontEnd_Control_QuangCao_Slider
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Bind2Repeater()
        End If
    End Sub
    Protected Sub Bind2Repeater()
        Using _data As New VSEntities
            'Add DomainName DUC 09-09-2014
            Dim p = (From q In _data.ImagesAdvers Where q.Domain = DomainName And q.StatusID = 3 And q.Subject = ImageAdverType.BannerHome Select q Order By q.Sort).Take(3).ToList
            With rptImage
                .DataSource = p
                .DataBind()
            End With
            'Add DomainName DUC 09-09-2014
            Dim k = (From q In _data.Contents Where q.Domain = DomainName And q.StatusId = 3 And q.PublishedDate <= Now() And (q.eEffectiveDate >= Now() Or q.eEffectiveDate Is Nothing) Order By q.PublishedDate Descending
         Select q).Take(8).ToList


            rptShow.DataSource = k
            rptShow.DataBind()
            ' hplMore.NavigateUrl = MainDomain & "tin-tuc.html"

        End Using
    End Sub


    Protected Sub rptImage_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptImage.ItemDataBound
        Dim row As VSModel.ImagesAdver = CType(e.Item.DataItem, VSModel.ImagesAdver)
        Dim hplTitle As HyperLink = CType(e.Item.FindControl("hplTitle"), HyperLink)


        hplTitle.NavigateUrl = row.URL
        hplTitle.Target = "_blank"
        Dim imgBig As Image = CType(e.Item.FindControl("imgBig"), Image)
        imgBig.ToolTip = row.Title
        imgBig.ImageUrl = row.SRC



    End Sub

    Protected Sub rptShow_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptShow.ItemDataBound
        '  hplTitle.NavigateUrl = MainDomain & "tin-tuc-chi-tiet/" & h.QueryString & "-" & h.Id.ToString & ".html"
        Dim row = CType(e.Item.DataItem, VSModel.Content)
        Dim hplTitle As HyperLink = CType(e.Item.FindControl("hplTitle"), HyperLink)
        hplTitle.Text = row.Title
        hplTitle.NavigateUrl = MainDomain & "tin-tuc-chi-tiet/" & row.QueryString & "-" & row.Id.ToString & ".html"
    End Sub

End Class
